<%--
    Document   : TimeInterval
    Created on : Dec 4, 2013, 5:40:47 PM
    Author     : NamDH
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">



<html lang="en">
    <head>
        <c:if test="${empty sessionScope.ACCOUNT}">
            <c:redirect url="../login.jsp"/>
        </c:if>
        <c:if test="${sessionScope.ACCOUNT.role.roleID == 3}">
            <c:redirect url="../home.jsp"/>
        </c:if>
        <c:set var="result" value="${param.result}"/>
        <c:if test="${not empty result}">
            <c:if test="${result == 'true'}">
                <script type="text/javascript">
                    alert("Update successfull!");
                </script>
            </c:if>
            <c:if test="${result == 'false'}">
                <script type="text/javascript">
                    alert("Update failed!");
                </script>
            </c:if>
        </c:if>

        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <title>PRTS - Admin Page</title>

        <!-- Bootstrap core CSS -->
        <link href="css/bootstrap.css" rel="stylesheet">

        <!-- Add custom CSS here -->
        <link href="css/sb-admin.css" rel="stylesheet">
        <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
        <!-- Page Specific CSS -->
        <link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.3.min.css">
        <!--         <script src="js/jquery-1.10.2.js"></script>-->
        <script src="../js/jquery-1.9.0.min.js"></script>
        <script src="js/bootstrap.js"></script>
        <script type="text/javascript">

            $(document).ready(function(){
                $('input:radio[name="radiobutton"]').change(
                function(){
                    //                    $('input:submit[name="btAction"]').disabled = false;
                    document.getElementById("btAction").disabled = false;
                   
                })
            });
        </script>
    </head>

    <body>

        <div id="wrapper">

            <!-- Sidebar -->
            <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <div id ="logo" style="float:left; padding:3px">
                        <a href="../home.jsp">
                            <img style="height: 80px" src="../Images/PRTS.png"/>
                        </a>
                    </div>

                    <div  style="color:white; font-size: 3em;margin: 20px 0 0 70px; float:left;">
                        <span>Admin Page</span>
                    </div>

                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse navbar-ex1-collapse">

                    <ul class="nav navbar-nav side-nav">
                        <li><a href="../home.jsp"><i class="fa fa-home"></i> Home page</a></li>
                        <li ><a href="Admin.jsp"><i class="fa fa-dashboard"></i> Dashboard</a></li>
                        <li><a href="../AdminController?btAction=loadUser"><i class="fa fa-users"></i> Users</a></li>
                        <li><a href="../AdminController?btAction=loadProduct"><i class="fa fa-tags"></i> Products</a></li>
                        <li class="active"><a href="TimeInterval.jsp"><i class="fa fa-clock-o"></i> Edit time interval</a></li>
                    </ul>

                    <ul class="nav navbar-nav navbar-right navbar-user">


                        <li id="dropdown-account" class="dropdown user-dropdown" style="max-height: 85px">
                            <a href="#" id="username-outer" class="dropdown-toggle" data-toggle="dropdown"> ${sessionScope.ACCOUNT.emailAddress} <b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li><a href="../home.jsp"><i class="fa fa-home"> </i> Home page</a></li>
                                <li><a href="../HomeController?btAction=logout"><i class="fa fa-power-off"></i> Log Out</a></li>
                            </ul>
                        </li>
                    </ul>
                </div><!-- /.navbar-collapse -->
            </nav>

            <div id="page-wrapper">

                <div class="row">
                    <div class="col-lg-12">
                        <h1> Edit time interval for updating price history </h1>
                        <ol class="breadcrumb">
                            <li><i class="fa fa-dashboard"></i><a href="Admin.jsp"> Dashboard</a></li>
                            <li class="active"><i class="fa fa-clock-o"></i> Edit time interval</li>
                        </ol>
                        <div class="alert alert-success alert-dismissable">
                            <form action="../AdminController">
                                <c:if test="${sessionScope.RADIO == 'auto'}">

                                    <input type="radio" name="radiobutton" value="manual">Update price history manual<br>
                                    <input type="radio" name="radiobutton" checked=""  value="auto" style="margin:20px 0 0 0">Update price history automatically<br>
                                    <div id="auto"  style="margin: 10px 0 0 10px">

                                        <p style="width:30%">Current time interval: ${sessionScope.TIMEINTERVAL} second(s) </p>

                                        <div style="display: inline">
                                            <input name="newTimeInterval" class="form-control" id="focusedInput" style="width: 30%;float:left;" type="number" min="1"  placeholder="Enter new time (second)...">

                                            <input type="submit" class="btn btn-info" style="margin: 0 0 0 10px" name="btAction" value="Update time"/>

                                        </div>

                                    </div>
                                </c:if>
                                <c:if test="${sessionScope.RADIO == 'manual'}">
                                    <input type="radio" name="radiobutton" checked="" value="manual">Update price history manual<br>
                                    <div id="manual">
                                        <input type="submit" class="btn btn-info" style="margin: 10px 0 0 0px" name="btAction" value="Run update"/><br>
                                    </div>

                                    <input type="radio" name="radiobutton" value="auto" style="margin:10px 0 0 0">Update price history automatically<br>
                                </c:if>
                                <br>
                                <input type="submit" class="btn btn-default" id="btAction" disabled name="btAction" value="  Save  "/>
                            </form>
                        </div>
                    </div>
                </div>





            </div><!-- /#page-wrapper -->

        </div><!-- /#wrapper -->

        <!-- JavaScript -->

        <script src="js/bootstrap.js"></script>

        <!-- Page Specific Plugins -->
        <script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
        <script src="http://cdn.oesmith.co.uk/morris-0.4.3.min.js"></script>
        <script src="js/morris/chart-data-morris.js"></script>
        <script src="js/tablesorter/jquery.tablesorter.js"></script>
        <script src="js/tablesorter/tables.js"></script>

    </body>
</html>

